unit Main;

interface

  uses
    Windows,
    Messages,
    SysUtils,
    StrUtils,
    Variants,
    Classes,
    Graphics,
    Controls,
    Forms,
    Dialogs,
    OleCtrls,
    SHDocVw,
    ExtCtrls,
    ActiveX,
    MSHTML,
    ExtActns,
    SHDocVw_EWB,
    EwbCore,
    EmbeddedWB,
    Menus,
    ComCtrls,
    StdCtrls;

  type
    TMainForm = class(TForm)
      Browser: TEmbeddedWB;
      procedure BrowserGetExternal(Sender: TCustomEmbeddedWB; var ppDispatch: IDispatch);
      procedure FormCreate(Sender: TObject);
      procedure BrowserTitleChange(ASender: TObject; const Text: WideString);
    end;

  var
    MainForm: TMainForm;

implementation

  {$R *.dfm}

  uses
    ExternalInterface,
    PootcherOptions,
    PootcherRoutines;


  procedure TMainForm.FormCreate(Sender: TObject);
  begin
    if Options.Debug then
    with Browser.DisableErrors do begin
      EnableDDE := false;
      fpExceptions := false;
      ScriptErrorsSuppressed := false;
    end;
    Browser.Navigate(Options.UpdaterPage);
    //Fix icon
    SetFormIcons(MainForm.Handle, 'MAINICON', 'MAINICON');
    //AboutForm.ShowModal();
  end;

  procedure TMainForm.BrowserGetExternal(Sender: TCustomEmbeddedWB;
  var ppDispatch: IDispatch);
    var ExtDispatch : TExternalInterface;
  begin
    ExtDispatch := TExternalInterface.Create();
    ppDispatch := ExtDispatch;
  end;

  procedure TMainForm.BrowserTitleChange(ASender: TObject;
  const Text: WideString);
  begin
    MainForm.Caption := Text;
  end;

end.
